
package com.jf.cloud.supplier.controller.platform;

import com.jf.cloud.common.response.ServerResponseEntity;
import com.jf.cloud.common.security.AuthUserContext;
import com.jf.cloud.supplier.dto.SupplierWithdrawCashConfigDto;
import com.jf.cloud.supplier.dto.SupplierWithdrawCashDTO;
import com.jf.cloud.supplier.service.SupplierWithdrawCashService;
import com.jf.cloud.supplier.vo.SupplierWithdrawCashVO;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zz
 * @Date 2021/6/11 9:28
 */
@RestController("platformSupplierWithdrawCashController")
@RequestMapping("/p/supplier_withdraw_cash")
@Tag(name = "platform-供应商提现申请信息")
public class SupplierWithdrawCashController {

    @Autowired
    private SupplierWithdrawCashService supplierWithdrawCashService;

    @GetMapping("/info")
    @Operation(summary = "根据提现记录id查看提现记录" , description = "根据提现记录id查看提现记录")
    public ServerResponseEntity<SupplierWithdrawCashVO> getById(@RequestParam(value = "cashId") Long cashId) {
        SupplierWithdrawCashVO supplierWithdrawCashVO = supplierWithdrawCashService.getDetailByCashId(cashId);
        return ServerResponseEntity.success(supplierWithdrawCashVO);
    }

    @PutMapping("/audit")
    @Operation(summary = "审核供应商提现信息" , description = "审核供应商提现信息")
    public ServerResponseEntity<Void> audit(@RequestBody SupplierWithdrawCashDTO supplierWithdrawCashDTO) {
        supplierWithdrawCashService.auditWithdrawCash(supplierWithdrawCashDTO, AuthUserContext.get().getUserId());
        return ServerResponseEntity.success();
    }

    @PostMapping("/save")
    @Operation(summary = "设置提现金额" , description = "设置提现金额")
    public ServerResponseEntity<Void> saveWithdrawCashConfig(@RequestBody SupplierWithdrawCashConfigDto supplierWithdrawCashConfigDto) {
        supplierWithdrawCashService.saveConfig(supplierWithdrawCashConfigDto);
        return ServerResponseEntity.success();
    }
    @GetMapping("/getWithdrawCash")
    public ServerResponseEntity<SupplierWithdrawCashConfigDto> getWithdrawCashConfig(){
        return ServerResponseEntity.success(supplierWithdrawCashService.getConfig());
    }

}
